
package com.jf.cloud.order.feign;

import com.jf.cloud.api.order.feign.OrderSettlementFeignClient;
import com.jf.cloud.api.order.vo.OrderSettlementPayVO;
import com.jf.cloud.api.order.vo.OrderSettlementSimpleVO;
import com.jf.cloud.common.response.ServerResponseEntity;
import com.jf.cloud.order.model.OrderSettlement;
import com.jf.cloud.order.service.OrderSettlementService;
import ma.glasnost.orika.MapperFacade;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RestController;
import io.swagger.v3.oas.annotations.Hidden;

import java.util.List;

/**
 * @author zz
 * @Date 2021/7/14 13:33
 */
@RestController
@Hidden
public class OrderSettlementFeignController implements OrderSettlementFeignClient {

    @Autowired
    private OrderSettlementService orderSettlementService;

    @Autowired
    private MapperFacade mapperFacade;

    @Override
    public ServerResponseEntity<List<OrderSettlementSimpleVO>> listOrderIdsByPayIds(Long userId, List<Long> payIds) {
        return ServerResponseEntity.success(orderSettlementService.listOrderIdsByPayIds(userId, payIds));
    }

    @Override
    public ServerResponseEntity<OrderSettlementPayVO> getPayIdByOrderId(Long orderId) {
        OrderSettlement orderSettlement = orderSettlementService.getByOrderId(orderId);
        return ServerResponseEntity.success(mapperFacade.map(orderSettlement, OrderSettlementPayVO.class));
    }
}
